#ifndef FILE_GameEngine_H
#define FILE_GameEngine_H
#include "Board.h"

#include "player_t.h"
#include "position_t.h"

struct GameInput{
	enum {PLACEPAWN,MOVEBALL,ENDMOVE,REQUEST_EXIT} action;
	position_t place;
};

class GameEngine{
public:
	static const player_t None;
	static const player_t P1;
	static const player_t P2;
	static const int turnLimit = 200;
	GameEngine();
	GameEngine(const Board& board, player_t currentPlayer = player_t(),int turnCount = 0);
	GameEngine(const GameEngine& from);
	/**
	 * \returns false if the game is over.
	 */
	bool step(const GameInput& gameInput);
	const Board& getBoard() const;
	player_t getCurrentPlayer() const;
	bool isInBallMove() const;
	bool getLastInputFailed() const;
	int getTurnCount() const;
	bool isGameOver() const;
	bool getWinner(player_t& winner) const;
private:
	/**
	 * \return true if the move was correct.
	 */
	bool ballMoveIfCorrect(position_t dest);
	Board m_board;
	player_t m_currentPlayer;
	bool m_lastInstructionFailed;
	bool m_inBallMove;
	int m_turnCount;
};


#endif // FILE_GameEngine_H